#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>

int main(int argc,char* argv[])
{
    //打开
    int fd = open(argv[1],O_WRONLY);
    if (-1==fd)
    {
        //删除管道文件
        printf("打开管道文件失败%m\n");
        unlink(argv[1]);
        return -1;
    }

    //读 c
    char buff[256];
    int n = 0;
    while (1)
    {
        printf("你要发送啥:");
        scanf("%s",buff);
        int r  = write(fd,buff,strlen(buff));

        printf("发送%d字节数据\n",r);
    }

    close(fd);

    return 0;
}